package com.example.sxt_practise.GOF23.prototype;

import java.io.Serializable;
import java.util.Date;

/**
 * @author gaofeng
 * @date 2022年05月21日 10:50
 */
public class Sheep implements Cloneable, Serializable {
    private String name ;
    private Date birthday ;

    public Sheep() {
    }

    public Sheep(String name, Date birthday) {
        this.name = name;
        this.birthday = birthday;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    /**
     *
     * @return java.lang.Object
     */
    @Override
    protected Object clone() throws CloneNotSupportedException {
        /// 浅拷贝,
        Object obj = super.clone();
        // 实现深复制,属性也拷贝
        Sheep sheep = (Sheep) obj ;
        sheep.birthday = (Date) this.birthday.clone();
        return sheep ;
    }
}
